package daoImpls;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import dao.DAO;
import dbc.ConnectionPool;
import vo.Category;
import vo.PetObject;

public class ObjectDAOImpl implements DAO<Object> {
    //final static ConnectionPool cp = new ConnectionPool(Integer.parseInt(ConnectionPool.getProperties("PoolSize")));
	ConnectionPool cp = new ConnectionPool();
    @Override
    public void add(PetObject hero) {
    }
    @Override
    public void update(PetObject hero) {
    }

    @Override
    public void delete(String id,String name) {
        try (Connection c = cp.getConnection(); Statement s = c.createStatement();) {
            String sql = "delete from "+ ConnectionPool.getProperties(this.getClass().getSimpleName()) +" where "+ name +" = '" + id + "'";
            System.out.println(sql);
            s.execute(sql);
            cp.returnConnection(c);
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
    }

    @Override
    public PetObject get(String id) {
        return null;
    }
    @Override
    public PetObject getU(String username) {
        return null;
    }

    @Override
    public List<PetObject> list() {
    	return null;
    }

    @Override
    public List<PetObject> list(int start, int count) {
       
        return null;
    }
	@Override
	public void deleteQuery(String ids,String name){
		try (Connection c = cp.getConnection(); Statement s = c.createStatement();) {
			String sql = "delete from "+ ConnectionPool.getProperties(this.getClass().getSimpleName()) +" where "+ name +" in (" + ids + ")";
				System.out.println(sql);
				s.execute(sql);
				cp.returnConnection(c);
		} catch (SQLException e) {
			System.out.println(e.getMessage());
		}
	}
}
